package com.exchange.interfaces.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.exchange.common.annotation.Log;
import com.exchange.common.enums.BusinessType;
import com.exchange.interfaces.domain.JgPublishDirectoryDetail;
import com.exchange.interfaces.service.IJgPublishDirectoryDetailService;
import com.exchange.common.core.controller.BaseController;
import com.exchange.common.core.page.TableDataInfo;
import com.exchange.common.core.domain.AjaxResult;
import com.exchange.common.utils.poi.ExcelUtil;

/**
 * 数据交换_目录清单子项 信息操作处理
 * 
 * @author exchange
 * @date 2019-06-04
 */
@Controller
@RequestMapping("/interfaces/jgPublishDirectoryDetail")
public class JgPublishDirectoryDetailController extends BaseController
{
    private String prefix = "interfaces/jgPublishDirectoryDetail";
	
	@Autowired
	private IJgPublishDirectoryDetailService jgPublishDirectoryDetailService;
	
	@RequiresPermissions("interfaces:jgPublishDirectoryDetail:view")
	@GetMapping()
	public String jgPublishDirectoryDetail()
	{
	    return prefix + "/jgPublishDirectoryDetail";
	}
	
	/**
	 * 查询数据交换_目录清单子项列表
	 */
	@RequiresPermissions("interfaces:jgPublishDirectoryDetail:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(JgPublishDirectoryDetail jgPublishDirectoryDetail)
	{
		startPage();
        List<JgPublishDirectoryDetail> list = jgPublishDirectoryDetailService.selectJgPublishDirectoryDetailList(jgPublishDirectoryDetail);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出数据交换_目录清单子项列表
	 */
	@RequiresPermissions("interfaces:jgPublishDirectoryDetail:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JgPublishDirectoryDetail jgPublishDirectoryDetail)
    {
    	List<JgPublishDirectoryDetail> list = jgPublishDirectoryDetailService.selectJgPublishDirectoryDetailList(jgPublishDirectoryDetail);
        ExcelUtil<JgPublishDirectoryDetail> util = new ExcelUtil<JgPublishDirectoryDetail>(JgPublishDirectoryDetail.class);
        return util.exportExcel(list, "jgPublishDirectoryDetail");
    }
	
	/**
	 * 新增数据交换_目录清单子项
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存数据交换_目录清单子项
	 */
	@RequiresPermissions("interfaces:jgPublishDirectoryDetail:add")
	@Log(title = "数据交换_目录清单子项", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(JgPublishDirectoryDetail jgPublishDirectoryDetail)
	{		
		return toAjax(jgPublishDirectoryDetailService.insertJgPublishDirectoryDetail(jgPublishDirectoryDetail));
	}

	/**
	 * 修改数据交换_目录清单子项
	 */
	@GetMapping("/edit/{manageDetailId}")
	public String edit(@PathVariable("manageDetailId") String manageDetailId, ModelMap mmap)
	{
		JgPublishDirectoryDetail jgPublishDirectoryDetail = jgPublishDirectoryDetailService.selectJgPublishDirectoryDetailById(manageDetailId);
		mmap.put("jgPublishDirectoryDetail", jgPublishDirectoryDetail);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存数据交换_目录清单子项
	 */
	@RequiresPermissions("interfaces:jgPublishDirectoryDetail:edit")
	@Log(title = "数据交换_目录清单子项", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(JgPublishDirectoryDetail jgPublishDirectoryDetail)
	{		
		return toAjax(jgPublishDirectoryDetailService.updateJgPublishDirectoryDetail(jgPublishDirectoryDetail));
	}
	
	/**
	 * 删除数据交换_目录清单子项
	 */
	@RequiresPermissions("interfaces:jgPublishDirectoryDetail:remove")
	@Log(title = "数据交换_目录清单子项", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(jgPublishDirectoryDetailService.deleteJgPublishDirectoryDetailByIds(ids));
	}
	
}
